<%= form_for(@car) do |f| %>
  <% if @car.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@car.errors.count, "error") %> prohibited this car from being saved:</h2>

      <ul>
      <% @car.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

    <%= f.hidden_field :user_id %>
    
  <div class="field">
    <%= f.label :car_brand_id %>
    <%= f.select :car_brand_id, options_from_collection_for_select(@car_brands, 'id', 'name', :selected => @car.car_brand_id) %>
  </div>    
    <div class = "field", id = "carModels">
		<%= render :partial => 'car_models', :locals => { :car_models => @car_models }  %>
	</div>
		
  <div class="field">
    <%= f.label :year %>
    <%= f.select :year, options_for_select(@years, :selected => @car.year) %><br />
  </div>
  <div class="field">
    <%= f.label :engine_type_id %>
    <%= f.select :engine_type_id, options_from_collection_for_select(@engine_types, 'id', 'name', :selected => @car.engine_type_id) %><br />
  </div>
  <div class="field">
    <%= f.label :gearbox_type_id %>
    <%= f.select :gearbox_type_id, options_from_collection_for_select(@gearbox_types, 'id', 'name', :selected => @car.gearbox_type_id) %><br />
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
